from radio_base import get_weekday_index

"""
Configuration for the radio scripts
===================================

"""


dir_="/var/www/gh/oe1" # This is the directory root for the assumed structure
url="http://mp3stream3.apasf.apa.at:8000/" # the radio stream to record
ripcmd="/usr/local/bin/radio_rip" # the command to rip the stream
weekdays=["mo","di","mi","do","fr","sa","so"] # name of the weekdays / direcotries
overflow_time=1 # min, recording lasts this time longer over the end (to prevent loss)
dateformat = "%d.%m.%Y" # the format the date is given to the scripts


# broadcasts: List of broadcasts to record
# Format [BROADCASTNAME, WEEKDAY, STARTTIME %H:%M, ENDTIME %H:%M]
# broadcastname and weekday must be unique

def add_snd(sendungen, wotage):
    erg = []
    for w in wotage:
        for s in sendungen:
            s[1] = w
            erg.append(list(s))
    return erg
    
broadcasts = []

# mo-so
broadcasts = broadcasts + \
             add_snd((['spielraeume','','17:30','17:55'],),
                     ['mo','di','mi','do','fr','sa','so'])


# mo-sa
broadcasts = broadcasts + \
             add_snd((['oe1_bis_2','','13:00','13:55'],
                      ['pasticcio','','08:15','08:55'],),
                     ['mo','di','mi','do','fr','sa'])

# mo-fr
broadcasts = broadcasts + \
             add_snd((['leporello','','07:52', '08:00'],
                      ['vom_leben_der_natur','','08:55','09:00'],
                      ['schon_gehoert','','11:35','11:40'],
                      ['wissen_aktuell','','13:55','14:00'],
                      ['moment_leben_heute','','14:40','14:55'],
                      ['kulturjournal','','17:09','17:30'],                    
                      ['betrifft_geschichte','','17:55','18:00'],
                      ['dimensionen','','19:06','19:30'],
                      ['zeit_ton','','23:03','24:00'],),
                     ['mo','di','mi','do','fr'])

# mo-do
broadcasts = broadcasts + \
             add_snd((['radiokolleg','','09:05','10:00'],
                      ['konzert_am_vormittag','','10:05','11:35'],
                      ['digital_leben','','16:55','17:00'],
                      ['journal_panorama','mo','18:25','18:55'],),
                     ['mo','di','mi','do'])

# mo-mi
broadcasts = broadcasts + \
             add_snd((['radiogeschichten','','11:40','12:00'],),
                     ['mo','di','mi'])

#di-fr
broadcasts = broadcasts + \
             add_snd((['von_tag_zu_tag','','14:03','14:40'],),
                     ['di','mi','do','fr'])

# mo
broadcasts = broadcasts + [                     
              ['medizin_und_gesundheit','mo','14:03','14:40'],
              ['musikgalerie','mo','15:05','16:00'],
              ['dacapo_hoerbilder','mo','16:00','16:55'],
              ['onstage','mo','19:30','20:00'],
              ['tonspuren','mo','21:00','21:40'],
              ['texte','mo','21:40','22:00'],]


# Di
broadcasts = broadcasts + [ \
    ['dacapo_ambiente','di','16:00','16:55'],
    ['alte_musik_neu_interpretiert','di','19:30','21:00'],
    ['hoerspiel_studio','di','21:00','22:00'],]

# Mi
broadcasts = broadcasts + [ \
    ['abenteuer_interpretation','mi','15:05','16:00'],
    ['dacapo_context','mi','16:00','16:40'],
    ['radiodoktor','mi','16:40','16:55'],
    ['philharmonisches','mi','19:30','21:00'],
    ['salzburger_nachtstudio','mi','21:00','22:00'],]

# Do
broadcasts = broadcasts + [ \
    ['terra_incognita','do','11:40','12:00'],
    ['apropos_kammermusik','do','15:05','16:00'],
    ['dacapo_tonspuren','do','16:00','16:40'],
    ['synchron_dasfilmmagazin','do','16:40','16:55'],
    ['stimmen_hoeren','do','19:30','21:00'],
    ['im_gespraech','do','21:00','22:00'],]

# Fr
broadcasts = broadcasts + [ \
    ['kontext','fr','09:05','09:45'],
    ['saldo','fr','09:45','10:00'],
    ['intrada','fr','10:05','11:35'],
    ['beispiele','fr','11:40','12:00'],
    ['apropos_musik','fr','15:05','16:00'],
    ['dacapo_imgespraech','fr','16:00','17:00'],
    ['europa_journal','fr','18:20','18:55'],
    ['aus_dem_konzertsaal_kabarett','fr','19:30','22:00'],
    ]

# Sa
broadcasts = broadcasts + [ \
    ['nachtbilder','sa','00:08','01:00'],
    ['kultur_aktuell','sa','07:22','07:32'],
    ['guten_morgen_oesterreich','sa','07:35','08:00'],
    ['hoerbilder','sa','09:05','10:00'],
    ['klassik_treffpunkt','sa','10:05','11:40'],
    ['help','sa','11:40','12:00'],
    ['hoerspiel_galerie','sa','14:00','15:00'],
    ['apropos_klassik','sa','15:05','16:57'],
    ['diagonal','sa','17:05','19:00'],
    ['extra','sa','22:05','23:00'],
    ['jazznacht','sa','23:03','24:00'],
    ]

# So
broadcasts = broadcasts + [ \
    ['guten_morgen_oesterreich','so','06:05','06:55'],
    ['du_holde_kunst','so','08:15','09:00'],
    ['patina','so','09:05','09:30'],
    ['welt_ahoi','so','09:30','09:55'],
    ['schon_gehoert','so','09:55','10:00'],
    ['ambiente','so','10:05','11:00'],
    ['matinee','so','11:03','12:56'],
    ['menschenbilder','so','14:03','14:55'],
    ['ganz_ich','so','16:30','17:00'],
    ['ex_libris','so','18:15','19:00'],
    ['aus_dem_konzertsaal','so','19:30','21:30'],
    ['heimspiel','so','21:30','21:55'],
    ['kontra','so','22:05','22:30'],
    ['matrix','so','22:30','23:00'],
    ['kunstradio','so','23:03','23:45'],
    ]

# sort by day and start
broadcasts.sort(lambda E1,E2: cmp(str(get_weekday_index(E1[1]))+E1[2],
                                  str(get_weekday_index(E2[1]))+E2[2]))
